<?php /*a:3:{s:44:"D:\www\long_shop\app\view\msg\msg_index.html";i:1702389679;s:42:"D:\www\long_shop\app\view\common\head.html";i:1702389678;s:48:"D:\www\long_shop\app\view\common\pagination.html";i:1702389678;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/jquery/jquery-1.12.4.min.js"></script>    
    <link href="/static/bst5.3.2/css/bootstrap.min.css" rel="stylesheet">
    <script src="/static/bst5.3.2/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="/static/bst-icons/font/bootstrap-icons.css">
    <script src="/static/layer/layer/layer.js"></script>
    <link rel="stylesheet" href="/static/css/my.css">    
</head>
<head>
<title>消息</title>

<style type="text/css">
</style>    
</head>
<body style="max-width: 1000px;">
  <div id="header"></div>

    
    <div class="container-fluid" >
    <div class="row">
        <div class="col-2" style="text-align: left;line-height: 50px;font-size: 2rem;" >
            留言管理
        </div>
        <div class="col-10" style="text-align: right;">
          <form action="/index.php/msg/index" method="post">
              <f id="query_bar" >
                  <label for="type" >消息类型：</label>
                  <select name="type" class="form-control" style="width:140px;display:initial;">
                      <option value="">所有类型</option>
                      <option value="3" <?php if($type==1): ?>selected<?php endif; ?>>系统提醒</option>
                      <option value="1,2" <?php if($type==2): ?>selected<?php endif; ?>>咨询与投诉</option>
                  </select>

                  <label for="text" >关键字</label>
                  <input class="form-control" type="text"  id="text" name="text" value="<?php echo htmlentities($text); ?>" placeholder="关键字" style="display: initial;" />
                  <button type="submit" class="btn btn-warning query" style="vertical-align: middle;" >
                      <span class="bi-search" ></span>
                  </button>

              </f>
          </form>          

        </div>
      </div>

      <table class="table table-sm table-striped">
        <tr>
          <th>序号</th>
          <th>发送人</th>
          <th>类型</th>
          <th>消息内容</th>
          <th>时间</th>
          <th>是否回复</th>
          <th>上传的图片</th>
          <th></th>
        </tr>
        <?php foreach($list['data'] as $k=>$kv): ?>
          <tr>
           <td><?php echo htmlentities($k+1); ?></td>
            <td><?php echo htmlentities($kv['customer_id_name']); ?></td>
            <td><?php echo htmlentities($kv['type_name']); ?></td>
            <td class="long_field"><?php echo htmlentities($kv['text']); ?></td>
            <td><?php echo htmlentities($kv['create_time']); ?></td>
            <td><?php echo htmlentities($kv['status_name']); ?></td>
            <td>
              <div>
              <?php if($kv['imgs']!=''): foreach($kv['imgs'] as $img): ?>
                <img class="goods_image" src='<?php echo htmlentities($img); ?>' style="height:40px;" />
              <?php endforeach; ?>
              <?php endif; ?>
              </div>
            </td>
            <td>
            <button class="btn btn-sm btn-info btn-view" txt ="<?php echo htmlentities($kv['text']); ?>" ><span class="bi-eye"></span> </button>
            <?php if($kv['type']<3): ?>
              <button class="btn btn-sm btn-primary btn-response" msg_id="<?php echo htmlentities($kv['id']); ?>"><span class="bi-pencil"></span> </button>
            <?php endif; if($kv['type']==3): ?>
              <button class="btn btn-sm btn-primary btn-contact" msg_id="<?php echo htmlentities($kv['id']); ?>"><span class="bi-check"></span> </button>
            <?php endif; ?>
            </td>
        </tr>
          <?php foreach($kv['res'] as $res): ?>
             <tr style="background: #cfe2ff;">
             <td></td>
              <td></td>
              <td >回复</td>
              <td class="long_field" ><?php echo htmlentities($res['text']); ?></td>
              <td ><?php echo htmlentities($res['create_time']); ?></td>
              <td><?php echo htmlentities($res['status_name']); ?></td>
              <td></td>
              <td></td>
              </tr>
          <?php endforeach; ?>
        <?php endforeach; ?>
      </table>
          <ul class="pagination pagination" >

        <?php if($list['current_page']>1): ?>
            <li class="page-item">
                <a class="page-link" href="?page=1<?php if(!empty($query)): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-double-left"></span>
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo htmlentities($list['current_page']-1); if(!empty($query)): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-left"></span>
                </a>
            </li>
        <?php endif; ?>

        <li class="page-item">
            <c class="page-link text-secondary"><?php echo htmlentities($list['current_page']); ?>/<?php echo htmlentities($list['last_page']); ?></c>
        </li>

        <?php if($list['current_page']<$list['last_page']): ?>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo htmlentities($list['current_page']+1); if(!empty($query) && $query!=''): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-right"></span>    <!--下一页-->
                </a>
            </li>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo htmlentities($list['last_page']); if(!empty($query)): ?><?php echo htmlentities($query); ?><?php endif; if(!empty($show_grid)): ?>&show_grid=<?php echo htmlentities($show_grid); ?><?php endif; ?>">
                    <span class="bi-chevron-double-right"></span>    <!--末页-->
                </a>
            </li>
        <?php endif; ?>


      </ul>
      <br/>
      
    </div>


<script type="text/javascript">
$(document).ready(function(){


    $(".goods_image").on('click',function(){
        var img = $(this).attr('src');
        if(!img.trim()) return;

        layer.open({
          type: 1,
          title:'',
          closeBtn: 0, //不显示关闭按钮
         // anim: 1,
          time: 5*1000,
          shadeClose: true, //开启遮罩关闭              
          skin: 'layui-layer-rim', 
          content: "<img src='"+img+"' style='width:100%'>"
        });
    })

    $(".btn-view").on('click',function(){
      var txt = $(this).attr('txt');
      layer.open({
        title:'查看消息',
        content:txt, 
        //type: 1,
        //skin: 'layui-layer-rim', //加上边框
        area: ['600px', '400px'] //宽高
      });

    })

    $(".btn-contact").on('click',function(){
      var id = $(this).attr('msg_id');
      $.post('/msg/set_readed',{id:id},function(res){
        console.log(res);
      })

    })    

    $(".btn-response").on('click',function(){
      var msg_id =$(this).attr('msg_id');
      layer.prompt({title: '回复消息', formType: 2}, function(text, index){
        layer.close(index);
        var text = text;

        $.post('/msg/msg_post',{to:msg_id,content:text,type:1},function(res){
          console.log(res);
        })

      });

    })







})


</script>


</body>
</html>
